package com.sky.wsp.spel.controller;

import com.sky.wsp.spel.annotation.SysLog;
import com.sky.wsp.spel.vo.UserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @desccription 在此输入描述
 * @auth wangshaopeng@talkweb.com.cn
 * @date 2022/7/19
 */
@RestController
@RequestMapping("spel")
public class SpelController {
    private Logger log = LoggerFactory.getLogger(SpelController.class);

    @GetMapping("create")
    @SysLog(tenantId = "#key", userId = "#result.id")
    public UserVO createUser(String key) {
        UserVO vo = new UserVO();
        vo.setId(System.currentTimeMillis());
        vo.setKey(key);
        return vo;
    }

    @GetMapping("update")
    @SysLog(tenantId = "#vo.key", userId = "#vo.id")
    public boolean updateUser(UserVO vo) {
        System.out.println("updateUser: tenantId:" + vo.getKey() + ", userId=" + vo.getId());
        return true;
    }

    @GetMapping("delete")
    @SysLog(tenantId = "#vo.key", userId = "#vo.id")
    public boolean deleteUser(UserVO vo) {
        System.out.println("deleteUser: tenantId:" + vo.getKey() + ", userId=" + vo.getId());
        return true;
    }
}
